Simplify the source sink interactions#368
Merged
mch2 merged 2 commits intoApr 17, 2026
Merged
Conversation
Signed-off-by: Bukhtawar Khan <bukhtawa@amazon.com>
Signed-off-by: Bukhtawar Khan <bukhtawa@amazon.com>
mch2
approved these changes
Apr 17, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
ExchangeSink/ExchangeSource split — The original ExchangeSink mixed write and read concerns in one interface (feed(), close(), readResult(), getRowCount(), getValueAt()). Split into write-only ExchangeSink (feed + close) in the analytics-framework SPI and read-only ExchangeSource (readResult + getRowCount) in the same module. RowProducingSink implements both as the backing store, with getValueAt kept as a concrete method. Producers only see ExchangeSink, the walker only sees ExchangeSource.
DataProducer/DataConsumer interfaces — The original SinkProvidingStageExecution was implemented by all stage types but meant different things on each. ShardFragmentStageExecution (a leaf) used it to expose the sink it writes into. PassThroughStageExecution and LocalStageExecution (middle nodes) used it to provide sinks to children. Introduced DataProducer (outputSink() + outputSource()) and DataConsumer (inputSink(int)). ShardFragmentStageExecution now implements only DataProducer. SinkProvidingStageExecution became a marker combining both for middle stages. The builder resolves sinks via DataConsumer, the walker reads results via DataProducer.
ResponseCodec extraction — The ~170 lines of scanResponseToArrow, inferArrowType, and setVectorValue were embedded in ShardFragmentStageExecution, coupling it to the Object[] wire format. Extracted into RowResponseCodec behind a ResponseCodec functional interface. The codec is injected by ShardFragmentStageScheduler. ShardFragmentStageExecution dropped from ~290 to ~120 lines with zero Arrow type-manipulation imports. Swapping to Arrow IPC transport means writing a new codec — no stage/sink/walker changes.
Two-phase scheduler (ExecutionGraph) — PlanWalker.walk() was monolithic: build graph + start execution in one call. Split into build() → ExecutionGraph → start(graph). ExecutionGraph is an inspectable intermediate representation holding all stage executions in CREATED state with listeners wired. Its explain() method returns a human-readable summary. QueryScheduler now has plan(config) for EXPLAIN (build-only, no dispatch) and execute(config, listener) for normal queries. The legacy walk() calls both for backward compatibility.
Related Issues
Resolves # opensearch-project#21242
Check List
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
For more information on following Developer Certificate of Origin and signing off your commits, please check here.